﻿<Window x:Class="SchemeManager.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:data="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
        xmlns:converter="clr-namespace:SchemeManager.Models"
        Title="智能电表参数设置 方案配置工具" Height="748" Width="1024" Closing="Window_Closing" WindowStartupLocation="CenterScreen" Icon="images\icon.ico" >
    <Window.Resources>
        <converter:Converter_EnumCheckType x:Key="Converter_EnumCheckType"/>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="44"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <ToolBar Grid.Row="0" Name="Tool_Buttons">
            <Button Name="Btn_Config" Style="{DynamicResource ToolBarButton}" Click="ToolBarButton_Click">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/images/Setting.png" Opacity="0.75" Width="32" Height="32"/>
                    <TextBlock Text="系统配置" VerticalAlignment="Center"/>
                </StackPanel>
            </Button>
            <Separator/>
            <Button Name="Btn_NewScheme" Style="{DynamicResource ToolBarButton}" Click="ToolBarButton_Click">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/images/Add.png" Opacity="0.75" Width="32" Height="32"/>
                    <TextBlock Text="新建方案" VerticalAlignment="Center"/>
                </StackPanel>
            </Button>
            <Button Name="Btn_SaveScheme" Style="{DynamicResource ToolBarButton}" Click="ToolBarButton_Click">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/images/Save.png" Opacity="0.75" Width="32" Height="32"/>
                    <TextBlock Text="保存方案" VerticalAlignment="Center"/>
                </StackPanel>
            </Button>
            <Button Name="Btn_DeleteScheme" Style="{DynamicResource ToolBarButton}" Click="ToolBarButton_Click">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/images/Delete.png" Opacity="0.75" Width="32" Height="32"/>
                    <TextBlock Text="删除方案" VerticalAlignment="Center"/>
                </StackPanel>
            </Button>
            <Separator/>
            <Button Name="Btn_Close" Style="{DynamicResource ToolBarButton}" Click="ToolBarButton_Click">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/images/Close.png" Opacity="0.75" Width="32" Height="32"/>
                    <TextBlock Text="关    闭" VerticalAlignment="Center"/>
                </StackPanel>
            </Button>
        </ToolBar>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition  Width="20*"/>
                <ColumnDefinition Width="80*"/>
            </Grid.ColumnDefinitions>
            <TabControl Margin="10" Effect="{DynamicResource Normal}">
                <TabItem Header="方案列表" Style="{DynamicResource TabItemStyle1}">
                    <ListBox 
                        Name="Lst_PrjItems" 
                        HorizontalAlignment="Stretch" 
                        BorderBrush="{DynamicResource selectedStroke}" 
                        FontSize="13.333" 
                        Background="#FFF0F0F0"
                        ItemsSource="{Binding}" 
                        SelectionChanged="Lst_PrjItems_SelectionChanged"
                        >
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" >
                                    <TextBlock Text="{Binding FAName}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </TabItem>
            </TabControl>
            <GridSplitter Margin="0,10,0,10" Width="2" ResizeDirection="Columns" Grid.Column="0" HorizontalContentAlignment="Center" VerticalAlignment="Stretch" ShowsPreview="True" />
            <!--右边部分表格-->
            <Grid Grid.Column="2">
                <Grid>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="Red">
                                        1、导入模板，增加参数时请先选择一个方案。2、要对参数进行移动，删除等请先选择一个参数项。3、要编辑某一个参数，请双击相应位置
                        </TextBlock>

                        <Grid Name="Grid_FaInfo" Grid.Row="1" Grid.Column="0">
                            <Grid.ColumnDefinitions >
                                <ColumnDefinition Width="300*"/>
                                <ColumnDefinition Width="120"/>
                            </Grid.ColumnDefinitions>
                            <DataGrid Name="Grid_Group" Grid.Row="0"
                                      BorderBrush="{DynamicResource selectedStroke}" 
                                  RowHeight="24" 
                                  VerticalContentAlignment="Center" 
                                  BorderThickness="1" 
                                  RowStyle="{DynamicResource DataGridRowStyle1}" 
                                  VerticalGridLinesBrush="{DynamicResource TabControlNormalBorderBrush}" 
                                  CellStyle="{DynamicResource DataGridCellStyle1}" 
                                  HorizontalGridLinesBrush="{DynamicResource TabControlNormalBorderBrush}"  
                                  IsSynchronizedWithCurrentItem="True" 
                                  CanUserSortColumns="False" 
                                  FontSize="12" 
                                  IsReadOnly="False" 
                                  AutoGenerateColumns="False"
                                  HeadersVisibility="Column" 
                                  CanUserReorderColumns="False"
                                  CanUserAddRows="False"
                                  SelectionMode="Single">
                                <DataGrid.GroupStyle>
                                    <GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
                                        <GroupStyle.Panel>
                                            <ItemsPanelTemplate>
                                                <DataGridRowsPresenter/>
                                            </ItemsPanelTemplate>
                                        </GroupStyle.Panel>
                                    </GroupStyle>
                                </DataGrid.GroupStyle>
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="参数类别" Width="80" Binding="{Binding Path=PrjType, Mode=OneWay}" IsReadOnly="True" />
                                    <DataGridTextColumn Header="项目名称" Width="90*" Binding="{Binding Path=PrjName, Mode=OneWay}" IsReadOnly="True" />
                                    <DataGridTextColumn Header="数据标识" Width="90*" Binding="{Binding Path=BsCode, Mode=OneWay}" IsReadOnly="True" />
                                    <DataGridTextColumn Header="数据域(可编辑)" Width="90*" Binding="{Binding Path=DataDomainDP, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" IsReadOnly="False"/>
                                    <DataGridComboBoxColumn Header="操作类型(可编辑)" Width="90*"  SelectedValueBinding="{Binding Path=ReviewType, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ResourceKey=Converter_EnumCheckType}}"/>
                                </DataGrid.Columns>
                            </DataGrid>

                            <!-- 相关的控制按钮-->
                            <Grid Grid.Column="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="100"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="120*"/>
                                </Grid.RowDefinitions>
                                <GroupBox Header="方案属性" Grid.Row="1" Margin="0,0,0,30">
                                    <CheckBox Name="cbFaReview" Content="方案仅复核"/>
                                </GroupBox> 
                                <StackPanel Grid.Row="2" Orientation="Vertical">
                                    <Button Name="btnImport" Margin="5"   Content="导入模板" Click="Button_Click"/>
                                    <Button Name="btnAddItems" Margin="5"   Content="增加参数" Click="Button_Click"/>
                                    <Button Name="btnDelete" Content="删除参数" VerticalAlignment="Center" Click="Button_Click" Margin="5"/>
                                    <Button Name="btnGroupUp"  Content="分组上移" Click="btnGroupUp_Click" Margin="5,30,5,5"/>
                                    <Button Name="btnGroupDown" Content="分组下移" Click="btnGroupDown_Click"  Margin="5"/>
                                    <Button Name="btnUp" Content="单个上移" VerticalAlignment="Center" Click="Button_Click" Margin="5"/>
                                    <Button Name="btnDown" Content="单个下移" VerticalAlignment="Center" Click="Button_Click" Margin="5" />

                                </StackPanel>
                            </Grid>
                        </Grid>
                    </Grid>
                </Grid>
            </Grid>

        </Grid>
    </Grid>
</Window>
